import * as THREE from 'three';

export default class AxisGridHelper {
    grid:THREE.GridHelper; 
    axes:THREE.AxesHelper;
    private _visible:boolean=true;
    constructor(node:THREE.Object3D,units=10){
        const axes = new THREE.AxesHelper();
        axes.material.depthTest = false;
        axes.renderOrder = 2; //网格渲染之后再渲染
        node.add(axes);

        const grid = new THREE.GridHelper(units,units);
        grid.material.depthTest = false;
        grid.renderOrder = 1;
        node.add(grid);

        this.grid = grid;
        this.axes = axes;
        this.visible = true;
    }

    get visible() {
        return this._visible;
    }

    set visible(v) {
        this._visible = v;
        this.grid.visible = v;
        this.axes.visible = v;
      }
}
